package com.xiaoshuidi.cloud.module.contract.service.contract.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xiaoshuidi.cloud.module.contract.dal.dataobject.contract.ContractFixedFeeVo;
import com.xiaoshuidi.cloud.module.contract.dal.mysql.contract.ContractFixedFeeMapper;
import com.xiaoshuidi.cloud.module.contract.service.contract.ContractFixedFeeService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @BelongsProject: lease-module-contract
 * @BelongsPackage: com.xiaoshuidi.cloud.module.contract.service.contract.impl
 * @Author: James
 * @CreateTime: 2023-11-15  10:11
 * @Description: 合同延期配置
 * @Version: 1.0
 */
@Service
@Slf4j
public class ContractFixedFeeServiceImpl extends ServiceImpl<ContractFixedFeeMapper, ContractFixedFeeVo> implements ContractFixedFeeService {

    @Resource
    private ContractFixedFeeMapper contractFixedFeeMapper;


    @Override
    public ContractFixedFeeVo getContractFiexdFee(Long apartmentId) {
        LambdaQueryWrapper<ContractFixedFeeVo> wrapper = Wrappers.lambdaQuery();
        wrapper.eq(ContractFixedFeeVo::getApartmentId,apartmentId);
        ContractFixedFeeVo contractFixedFeeVo = contractFixedFeeMapper.selectOne(wrapper);
        return contractFixedFeeVo;
    }

    @Override
    public Boolean updateContractFiexdFee(ContractFixedFeeVo contractFixedFeeVo) {
        LambdaUpdateWrapper<ContractFixedFeeVo> updateWrapper = new LambdaUpdateWrapper<>();
        updateWrapper.set(ContractFixedFeeVo::getIsFixedFee,contractFixedFeeVo.getIsFixedFee());
        updateWrapper.set(ContractFixedFeeVo::getFixedFee,contractFixedFeeVo.getFixedFee());
        updateWrapper.set(ContractFixedFeeVo::getIsRoomRate,contractFixedFeeVo.getIsRoomRate());
        updateWrapper.set(ContractFixedFeeVo::getRoomRate,contractFixedFeeVo.getRoomRate());
        updateWrapper.set(ContractFixedFeeVo::getRentFreePeriod,contractFixedFeeVo.getRentFreePeriod());
        updateWrapper.set(ContractFixedFeeVo::getContractDepositEditing,contractFixedFeeVo.getContractDepositEditing());
        updateWrapper.set(ContractFixedFeeVo::getContractRentEditing,contractFixedFeeVo.getContractRentEditing());
        updateWrapper.set(ContractFixedFeeVo::getBillPrint,contractFixedFeeVo.getBillPrint());
        updateWrapper.set(ContractFixedFeeVo::getCustomTime,contractFixedFeeVo.getCustomTime());
        updateWrapper.set(ContractFixedFeeVo::getCustomTime2,contractFixedFeeVo.getCustomTime2());
        updateWrapper.set(ContractFixedFeeVo::getRenewalContractPersonage,contractFixedFeeVo.getRenewalContractPersonage());
        updateWrapper.set(ContractFixedFeeVo::getRenewalContractEnterprise,contractFixedFeeVo.getRenewalContractEnterprise());
        updateWrapper.eq(ContractFixedFeeVo::getId,contractFixedFeeVo.getId());
        contractFixedFeeMapper.update(null, updateWrapper);
        return true;
    }
}
